package com.schoolai.entity.jpa;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 用户信息表
 * </p>
 *
 * @author bobby
 * @since 2025-10-14
 */
@Data
@Entity
@Schema(name = "SysUser", description = "用户信息表")
public class SysUser implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 用户 ID
     */
    @Id
    @GeneratedValue(strategy= GenerationType.UUID)
    @Schema(description = "用户 ID")
    private String id;

    /**
     * 用户名
     */
    @Schema(description = "用户名")
    private String username;

    /**
     * 密码，加密存储, admin/1234
     */
    @Schema(description = "密码，加密存储, admin/1234")
    private String password;

    /**
     * 帐户是否过期(1 未过期，0已过期)
     */
    @Schema(description = "帐户是否过期(1 未过期，0已过期)")
    private Integer isAccountNonExpired;

    /**
     * 帐户是否被锁定(1 未过期，0已过期)
     */
    @Schema(description = "帐户是否被锁定(1 未过期，0已过期)")
    private Integer isAccountNonLocked;

    /**
     * 密码是否过期(1 未过期，0已过期)
     */
    @Schema(description = "密码是否过期(1 未过期，0已过期)")
    private Integer isCredentialsNonExpired;

    /**
     * 帐户是否可用(1 可用，0 删除用户)
     */
    @Schema(description = "帐户是否可用(1 可用，0 删除用户)")
    private Integer isEnabled;

    /**
     * 昵称
     */
    @Schema(description = "昵称")
    private String nickName;

    /**
     * 头像url
     */
    @Schema(description = "头像url")
    private String imageUrl;

    /**
     * 注册手机号
     */
    @Schema(description = "注册手机号")
    private String mobile;

    /**
     * 注册邮箱
     */
    @Schema(description = "注册邮箱")
    private String email;

    /**
     * 创建时间
     */
    @Schema(description = "创建时间")
    private Date createDate;

    /**
     * 更新时间
     */
    @Schema(description = "更新时间")
    private Date updateDate;

    /**
     * 密码更新时间
     */
    @Schema(description = "密码更新时间")
    private Date pwdUpdateDate;

    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(
            name = "sys_user_role",
            joinColumns = @JoinColumn(name = "user_id"),
            inverseJoinColumns = @JoinColumn(name = "role_id")
    )
    private List<SysRole> sysRoleList = new ArrayList<>();;

}
